package easy;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public class Solution_1207 {

    public boolean uniqueOccurrences(int[] arr) {
        int[] array = new int[2001];
        for (int num : arr) {
            array[num+1000]++;
        }
        boolean[] flags = new boolean[1000];
        for (Integer count : array) {
            if (count == 0) {
                continue;
            }
            if (flags[count]) {
                return false;
            }
            flags[count] = true;
        }
        return true;
    }

    /*public boolean uniqueOccurrences(int[] arr) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int num : arr) {
            Integer count = map.getOrDefault(num, 0);
            count++;
            map.put(num, count);
        }
        boolean[] flags = new boolean[1000];
        for (Integer key : map.keySet()) {
            Integer count = map.get(key);
            if (flags[count]) {
                return false;
            }
            flags[count] = true;
        }
        return true;
    }*/

    public static void main(String[] args) {
        Solution_1207 model = new Solution_1207();
        System.out.println(model.uniqueOccurrences(new int[]{1, 2, 2, 1, 1, 3}));
        System.out.println(model.uniqueOccurrences(new int[]{1,2}));
    }
}
